﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nutrapp.Test
{
    public static class MathHelper
    {
        public static int getFraction(int number)
        {
            int result = 1;
            if (number> 0)
            {
                for (int i = number; i > 0; i--)
                {
                    result = result * i;
                }
            }
            return result;
        }

        public static int get_allComboes_for_aList (int size)
        {
            int result = 0;
            if (size > 0)
            {
                for (int i = 1; i <= size; i++)
                {
                    result += get_allComboes_for_N_elements_inThelist(size, i);
                }
            }
                return result;
        }

        public static int get_allComboes_contains_N_elements_inList(int size, int nElements)
        {
            int result = 0;
            if (nElements <= size)
            {
                int comboes_for_rest_elements = get_allComboes_for_aList(size - nElements);
                result = comboes_for_rest_elements + 1;
            }
            return result;
        }

        public static int get_allComboes_for_N_elements_inThelist(int size, int nElements)
        {
            int result = 0;
            if (size > 0 && nElements > 0)
            {
                result = getFraction(size) / (getFraction(size - nElements) * getFraction(nElements));
            }
            return result;
        }

        public static int get_allComboes_consist_atLeast_oneOf_N_elenments_inList(int size, int nElements)
        {
            int result = 0;
            if (nElements <= size)
	        {
		        int allComboes = get_allComboes_for_aList(size);
                int comboes_notContains_any_elenment_in_nElements = get_allComboes_for_aList(size - nElements);
                result = allComboes - comboes_notContains_any_elenment_in_nElements;
	        }
            return result;
        }
    }
}
